﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Battleship
{
    public partial class WaterMeasurement : Form
    {
        private WaterBucket waterBucket, bucket;
       
        public WaterMeasurement(WaterBucket bucket)
        {
            InitializeComponent();

            Point location = new Point(15, 90);
            Size size = new Size(this.Width - 45, 110);
            waterBucket = new WaterBucket(location, size, bucket.getPercent(), Color.RoyalBlue, Color.Purple, false);
            this.Controls.Add(waterBucket);
            this.bucket = bucket;

            this.numWaterLevel.Text = bucket.getPercent() + "";
            this.tbrWaterLevel.Value = bucket.getPercent();
        }

        private void WaterMeasurement_FormClosed(object sender, FormClosedEventArgs e)
        {
            bucket.setPercent(tbrWaterLevel.Value);
        }

        private void numWaterLevel_ValueChanged(object sender, EventArgs e)
        {
            tbrWaterLevel.Value = Int16.Parse(numWaterLevel.Text);
        }

        private void tbrWaterLevel_ValueChanged(object sender, EventArgs e)
        {
            int percent = tbrWaterLevel.Value;
            waterBucket.setPercent(percent);

            this.numWaterLevel.Text = percent + "";
        }

        
    }
}
